package com.als.healthymananger.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;

/**
 * 公共返回对象
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RespBean {
    private int code;
    private String message;
    private Object data;

    /**
     * 成功不返回结果
     * @param message
     * @return
     */
    public static RespBean ok(String message) {
        return new RespBean(200, message, null);
    }

    /**
     * 成功返回结果
     * @param message
     * @param data
     * @return
     */
    public static RespBean ok(String message, Object data) {
        return new RespBean(200, message, data);
    }

    /**
     * 失败不返回结果
     * @return
     */
    public static RespBean badRequest(String message) {
        return new RespBean(400, message, null);
    }

    /**
     * 失败返回结果
     * @param message
     * @param data
     * @return
     */
    public static RespBean badRequest(String message, Object data) {
        return new RespBean(400, message, data);
    }
}
